
#pragma once

#include <string>
#include <vector>
#include <map>

#ifndef BOOL
#define BOOL  int
#endif

#ifndef TRUE
#define TRUE  1
#endif

#ifndef FALSE
#define FALSE  0
#endif

#ifndef BYTE
#define BYTE  unsigned char
#endif

#ifndef UINT
#define UINT  unsigned int
#endif

#ifndef WORD
#define WORD  unsigned short
#endif

#ifndef DWORD
#define DWORD  unsigned long
#endif

#ifndef LPCTSTR
#define LPCTSTR  char const*
#endif

#ifndef MAX_PATH
#define MAX_PATH 4095
#endif

inline auto is_sp(char c) -> bool
{
    return c == ' ' || c =='\t';
}

inline auto is_not_sp(char c) -> bool
{
    return c != ' ' && c != '\t';
}

template <typename Iter>
inline auto find_not_sp(Iter cur, Iter end)->Iter
{
    while(cur != end && is_sp(*cur))
        ++cur;
    return cur;
}

inline auto find_not_sp(std::string::iterator cur, std::string::iterator end)->std::string::iterator
{
    while(cur != end && is_sp(*cur))
        ++cur;
    return cur;
}

template <typename Iter>
inline auto find_last_not_sp(Iter cur, Iter end)->Iter
{
    using TIter = std::reverse_iterator<Iter>;
    return find_not_sp(TIter(end), TIter(cur)).base();
}

inline auto find_last_not_sp(std::string::iterator cur, std::string::iterator end)->std::string::iterator
{
    using TIter = std::reverse_iterator<std::string::iterator>;
    return find_not_sp(TIter(end), TIter(cur)).base();
}

//int GetModuleFileName(char* name, int size)
//{
//  FILE* stream = fopen("/proc/self/cmdline", "r");
//  fgets(name, size, stream);
//  fclose(stream);

//  return static_cast<int>(strlen(name));
//}
